import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_plan_record_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/hidden_danger_investigation_ledger_entity.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';
import 'package:get/get.dart';

///排查计划详情
class InvestigationPlanLedgerDetailController extends GetxController {
  HiddenDangerInvestigationLedgerRecords hiddenDangerInvestigationLedgerRecords = Get.arguments as HiddenDangerInvestigationLedgerRecords;
  List<GetPlanRecordEntity> getPlanRecordEntity = [];

  ///点击条目
  void onClickDetailDetail(GetPlanRecordEntity item) {
    Get.toNamed(AppRoutes.investigationPlanLedgerDetailDetail, arguments: {
      'planId': item.planId,
      'unitId': item.riskUnitId,
      'riskUnitName': item.riskUnitName,
    });
  }

  ///点击条目上活体识别
  void onClickOnDetailDetail() {
    Get.toNamed(AppRoutes.livingBodyRecognitionDetail);
  }

  @override
  void onInit() {
    super.onInit();
    //点击排查计划查看单元详情
    _getPlanRecord();
  }

  ///点击排查计划查看单元详情
  void _getPlanRecord() async {
    final res = await HttpUtil().generateGetRequest<List<GetPlanRecordEntity>>(Interface.getPlanRecord,
        queryParameters: {'planId': hiddenDangerInvestigationLedgerRecords.id}).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        getPlanRecordEntity = result.data!;
        update();
      }
    });
  }
}
